home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 February / PCWFEB08.iso / Software / Freeware / Miro 1.0 / Miro_Installer.exe / Miro_Downloader.exe / xml / dom / minicompat.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2007-11-12  |  3.2 KB  |  88 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.5)
  3.  
  4. '''Python version compatibility support for minidom.'''
  5. __all__ = [
  6.     'NodeList',
  7.     'EmptyNodeList',
  8.     'StringTypes',
  9.     'defproperty']
  10. import xml.dom as xml
  11.  
  12. try:
  13.     unicode
  14. except NameError:
  15.     StringTypes = (type(''),)
  16.  
  17. StringTypes = (type(''), type(unicode('')))
  18.  
  19. class NodeList(list):
  20.     __slots__ = ()
  21.     
  22.     def item(self, index):
  23.         if index <= index:
  24.             pass
  25.         elif index < len(self):
  26.             return self[index]
  27.         
  28.  
  29.     
  30.     def _get_length(self):
  31.         return len(self)
  32.  
  33.     
  34.     def _set_length(self, value):
  35.         raise xml.dom.NoModificationAllowedErr("attempt to modify read-only attribute 'length'")
  36.  
  37.     length = property(_get_length, _set_length, doc = 'The number of nodes in the NodeList.')
  38.     
  39.     def __getstate__(self):
  40.         return list(self)
  41.  
  42.     
  43.     def __setstate__(self, state):
  44.         self[:] = state
  45.  
  46.  
  47.  
  48. class EmptyNodeList(tuple):
  49.     __slots__ = ()
  50.     
  51.     def __add__(self, other):
  52.         NL = NodeList()
  53.         NL.extend(other)
  54.         return NL
  55.  
  56.     
  57.     def __radd__(self, other):
  58.         NL = NodeList()
  59.         NL.extend(other)
  60.         return NL
  61.  
  62.     
  63.     def item(self, index):
  64.         pass
  65.  
  66.     
  67.     def _get_length(self):
  68.         return 0
  69.  
  70.     
  71.     def _set_length(self, value):
  72.         raise xml.dom.NoModificationAllowedErr("attempt to modify read-only attribute 'length'")
  73.  
  74.     length = property(_get_length, _set_length, doc = 'The number of nodes in the NodeList.')
  75.  
  76.  
  77. def defproperty(klass, name, doc):
  78.     get = getattr(klass, '_get_' + name).im_func
  79.     
  80.     def set(self, value, name = name):
  81.         raise xml.dom.NoModificationAllowedErr('attempt to modify read-only attribute ' + repr(name))
  82.  
  83.     if not not hasattr(klass, '_set_' + name):
  84.         raise AssertionError, 'expected not to find _set_' + name
  85.     prop = property(get, set, doc = doc)
  86.     setattr(klass, name, prop)
  87.  
  88.